package ui;

import Pojo.Book;
import Pojo.Reader;
import Service.LibraryService;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class BookCheckManger  extends JDialog implements ActionListener {
    private Book book ;
    private  LibraryManage libraryManage;
    private  JPanel contentPanel = new JPanel();
    private  JTextField txtBookId ;
    private  JTextField txtBookName;
    private  JTextField txtBookType;
    private  JTextField txtloanReaderId;

    private LibraryService libraryService = new LibraryService();
    public BookCheckManger(Book book , LibraryManage libraryManage){
        this.book = book;
        this.libraryManage = libraryManage;
        setTitle("借阅信息查看");
        setBounds(100,100,570,474);
        getContentPane().setLayout(new BorderLayout());
        contentPanel.setBorder(new EmptyBorder(5,5,5,5));
        getContentPane().add(contentPanel, BorderLayout.CENTER);
        contentPanel.setLayout(null);

        JLabel labelBookId = new JLabel("图书编号");
        labelBookId.setBounds(160,40,60,15);
        contentPanel.add(labelBookId);
        txtBookId = new JTextField();
        txtBookId.setBounds(230,39,170,28);
        txtBookId.setColumns(10);
        contentPanel.add(txtBookId);

        JLabel labelBookName = new JLabel("图书名称");
        labelBookName.setBounds(160,90,60,15);
        contentPanel.add(labelBookName);
        txtBookName = new JTextField();
        txtBookName.setBounds(230,85,170,28);
        txtBookName.setColumns(10);
        contentPanel.add(txtBookName);

        JLabel labelBookType = new JLabel("图书作者");
        labelBookType.setBounds(160,140,60,15);
        contentPanel.add(labelBookType);
        txtBookType = new JTextField();
        txtBookType.setBounds(230,140,170,28);
        txtBookType.setColumns(10);
        contentPanel.add(txtBookType);

        JLabel labelloanReaderId = new JLabel("借阅人");
        labelloanReaderId.setBounds(160,190,60,15);
        contentPanel.add(labelloanReaderId);
        txtloanReaderId = new JTextField();
        txtloanReaderId.setBounds(230,190,170,28);
        txtloanReaderId.setColumns(10);
        contentPanel.add(txtloanReaderId);

        JButton btnCanel = new JButton("取消");
        btnCanel.setBounds(305,240,165,35);
        btnCanel.addActionListener(this);
        contentPanel.add(btnCanel);
        this.setModal(true);

        txtBookId.setText(book.getBookId());
        txtBookName.setText(book.getBookName());
        txtBookType.setText(book.getBookType());
        txtloanReaderId.setText(book.getLoanReaderId());
        txtBookId.setEditable(false);
        txtBookName.setEditable(false);
        txtBookType.setEditable(false);
        txtloanReaderId.setEditable(false);
        this.setVisible(true);
    }


    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getActionCommand().equals("取消")){
            this.dispose();
        }

    }
}
